<?php

namespace App\Console\Commands\Listing;

use App\Http\Controllers\Logic\ProjectYsLogic;
use App\Http\Controllers\Logic\SendEmailLogic;
use App\Http\Controllers\OATrait\OATrait;
use App\Model\OAFinance;
use App\Model\OAProjectLx;
use Illuminate\Console\Command;

class SendEmail extends Command
{
    use OATrait;
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'Listing:SendEmail';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '每天发送邮箱';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        try{
            //$this->generateBatchId(1,1);
//            $lxList = OAProjectLx::query()->select(['id','gsid','deptid'])->get();
//            foreach ($lxList as $lx){
//                $batchID = $this->generateBatchId($lx->gsid,$lx->deptid,$lx->id);
//                $lx->batch_id = $batchID;
//                $lx->save();
//            }
            //dd(11);
            $finance_list = OAFinance::query()->select(['id','xmid'])->get();
           foreach ($finance_list as $finance){
               $batch_id = OAProjectLx::query()->where('id',$finance->xmid)->value('batch_id');
               $finance->batch_id = $this->generateFinanceBatchNum($batch_id);
               $finance->save();
           }






        }catch(\Exception $e){
            exit($e->getMessage());
        }
    }
}
